<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<html>
<head>
    <meta charset="UTF-8">
    <base href="<%=basePath%>">
    <title>电子商务平台——后台登录页</title>
    <!-- 引入EasyUI的相关css和js文件 -->
<%--    <link href="EasyUI/themes/default/easyui.css" rel="stylesheet" type="text/css"/>--%>
<%--    <link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css"/>--%>
<%--    <link href="EasyUI/demo.css" rel="stylesheet" type="text/css"/>--%>
<%--    <script src="EasyUI/jquery.min.js" type="text/javascript"></script>--%>
<%--    <script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>--%>
<%--    <script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>--%>

    <link rel="stylesheet" type="text/css" href="EasyUI/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="EasyUI/themes/icon.css">
<%--    <link rel="stylesheet" type="text/css" href="EasyUI/demo.css">--%>
    <script type="text/javascript" src="EasyUI/jquery.min.js"></script>
    <script type="text/javascript" src="EasyUI/jquery.easyui.min.js"></script>
</head>

<body>
<div id="adminLoginDlg" class="easyui-dialog"
     style="left: 550px; top: 200px;width: 300px;height: 200px"
     data-options="title:'后台登录',buttons:'#bb',modal:true">
    <form id="adminLoginForm" method="post">
        <table style="margin:20px;font-size: 13px;">
            <tr>
                <th>用户名:</th>
                <td><input class="easyui-textbox" type="text" id="name"
                           name="name" data-options="required:true" value="admin"/></td>
            </tr>
            <tr>
                <th>密码:</th>
                <td>
                    <%--图片资源路劲在EasyUI\themes\default\images下的passwordbox_close.png和passwordbox_open.png--%>
                    <%--修改icon.css可以自定义图标--%>
                        <%--自定义图标的文件放在icons文件夹--%>
                    <input id="pwd" class="easyui-passwordbox" passwordChar="❦" name="pwd" prompt="password" iconWidth="28"
                           value="123456" style=""/>
                </td>
            </tr>
        </table>

    </form>
</div>
<div id="bb">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="checkAdminLogin()">登录</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm();">重置</a>
</div>
<script type="text/javascript">
    /*重置按钮*/
    function clearForm() {
        $('#adminLoginForm').form('clear');
    }

    /*登录按钮*/
    function checkAdminLogin() {
        $("#adminLoginForm").form("submit", {
            // 向控制器类AdminInfoController中login方法发送请求
            url: 'adminInfo/login',
            success: function (result) {
                var result = eval('(' + result + ')');
                if (result.success == 'true') {
                    window.location.href = 'admin.jsp';
                    $("#adminLoginDlg").dialog("close");
                } else {
                    /*$.messager.show({
                        title: "提示信息",
                        msg: result.message
                    });*/
                    $.messager.alert('提示', result.message, 'info');
                }
            }
        });
    }
    /**给textbox添加回车事件*/
    $("#pwd").textbox({
        inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents,{
            keyup:function(event){
                if(event.keyCode == 13){
                    checkAdminLogin();	//回车保存
                }
            }
        })
    });

</script>
</body>
</html>